<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-cascades"></i> 光照历史数据</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-select  v-model="select_cate" placeholder="近三天" class="handle-select mr10">
                    <el-option key="1" label="近三天" value="3"></el-option>
                    <el-option key="2" label="本周内" value="7"></el-option>
                    <el-option key="3" label="本月内" value="30"></el-option>
                </el-select>
                <el-button type="primary" icon="search" @click="search">搜索</el-button>
            </div>
            <el-table :data="tableData" border class="table" ref="multipleTable" >
                <el-table-column prop="water_time" label="时间" sortable width="500"  align="center">
                </el-table-column>
                <el-table-column prop="water" label="光照"  align="center">
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination background @current-change="handleCurrentChange" layout="prev, pager, next" :total="1000">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
    import {getWaterLib} from '../../api/api'
    export default {
        data() {
            return {
                tableData: [],
                cur_page: 1,
                select_cate:'3',
                is_search: false
            }
        },
        created() {
            this.getData();
        },
        computed: {
            data() {
                return {}
            }
        },
        methods: {
            // 分页导航
            handleCurrentChange(val) {
                this.cur_page = val;
                this.getData();
            },
            // 获取 easy-mock 的模拟数据
           getData(){
                let param = {page: this.cur_page,day:this.select_cate};
                console.log('param',param);
                getWaterLib(param).then((res) => {
                    this.tableData = res;
                    console.log(res);
                })
            },
            search() {
                this.is_search = true;
            }
        }
    }

</script>

<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 120px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
    }
    .del-dialog-cnt{
        font-size: 16px;
        text-align: center
    }
    .table{
        width: 100%;
        font-size: 14px;
    }
    .red{
        color: #ff0000;
    }
</style>
